<?php

/*************************************************************************
Module static
----------------------------------------------------------------
Derasoft CMS Project
Company: Derasoft Co., Ltd                                  
Name: Tran Thi KIm Que                                   
Last updated: 07/01/2009
**************************************************************************/

#end company
include_once(ROOT_PATH."classes/dao/resources.class.php");
include_once(ROOT_PATH."classes/dao/galleries.class.php");
include_once(ROOT_PATH."includes/functions.php");
$templateFile = "gallery.tpl.html";
$gallery = new Gallery();
$resource = new Resource();
$template->assign('gallery',$gallery);
$template->assign('resource',$resource);
$slug = $request->element('slug','');
$page = $request->element('page',1);
$products_per_page = $siteConfigs->getProperty('products_per_page');
if($slug){
	$aid = $gallery->getIdFromSlug("slug='$slug'");
	$template->assign('aid',$aid);
	$subalbumItems= $gallery->getSubGallery($aid);
	//print_r($subalbumItems);
	$template->assign('subalbumItems',$subalbumItems);
	$resourceItems = $resource->getObjects($page,"status =1 AND aid=$aid ",array('date_created'=>'DESC'),'');
	//print_r($resourceItems);
	$template->assign('resourceItems',$resourceItems);
	$pages = $resource->getNumItems('id',"status = 1 ",$products_per_page);
	$rows = $pages['rows'];
	$pages = $pages['pages'];
	
	if(!$pages) $pages=1;
	if($page>$pages) $page=$pages;
	if(URL_TYPE==1)
			$listPage = linkPager1_en(ROOTPATH."/index.php?op=gallery&amp;slug=$slug&amp;lang=$lang&amp;page=%s",$pages,$page);
		else
			$listPage = linkPager1_en(ROOTPATH."/$lang/$slug/page-%s.html",$pages,$page);
		$template->assign("Pager",$listPage);
	$template->assign("pages",$pages);
	
}
$pageName="Download";
$template->assign("pageName",$pageName);

#end product
include_once(ROOT_PATH."modules/framework.module.php");

 $active='anh-cong-trinh';
  $template->assign('active',$active);
?>